﻿/**
 * @author Colin
 */
class com.mixmedia.browser.JS {
	public static var debugMode:Boolean = false;
	public static var enableExternalConnect:Boolean=true;
	
	public static function call(method:String,parameter:Object):Object{
		var strParameter = "";
		for(var i=1;i<arguments.length;i++){
			if(typeof(arguments[i])=='number'){
				strParameter+=arguments[i];
			}else{
				strParameter+="\""+String(arguments[i])+"\"";
			}
			if(i<arguments.length-1)strParameter+=",";
		}
		if(JS.debugMode!=true&&enableExternalConnect==true){
			getURL('javascript:'+method+"("+strParameter+");");
		}else{
			trace('javascript:'+method+"("+strParameter+");");
		}
		return null;
	}
	
	public static function observe(scope,str:String,fnt:Function,userData:Object):Void{
		scope.watch(str,fnt,userData);
	}
}